package cn.yuanqiao.activiti.listener;

import cn.yuanqiao.activiti.util.Archive;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;

import java.util.List;

/**
 * @ClassName: ManagerApprovalListener
 * @Description: 类的描述
 * @author: lihuahua
 * @date: 2023/6/8 16:43
 * @Blog: huahuacoco.top
 */

public class ManagerApprovalListener implements TaskListener, ExecutionListener {




    @Override
    public void notify(DelegateTask delegateTask) {
        // 获取流程变量 archiveList
        List<Archive> archiveList = (List<Archive>) delegateTask.getExecution().getVariable("archiveList");
        System.out.println("流程结束，退回归档");
        // 根据 archiveList 中的属性分配任务
        for (Archive archive : archiveList) {
            if (archive.isOurs()) {
                delegateTask.addCandidateUser("deptLeader");
            } else {
                delegateTask.addCandidateUser("archiveLeader");
            }
        }
    }
    @Override
    public void notify(DelegateExecution execution) {

    }
}